/*
 * AbstractGraphicsObject.java
 *
 * Created on 28. maaliskuuta 2007, 16:23
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package flowchart.nodes;

import java.awt.*;

/**
 *
 * @author jl
 */
public abstract class AbstractGraphicsObject implements GraphicsObject,java.io.Serializable {

    protected Color bgColor;
    protected Rectangle bounds;
    protected String title;
    protected boolean selected;
    protected int zindex;

    /** Creates a new instance of AbstractGraphicsObject */
    public AbstractGraphicsObject() {
        bgColor = null;
        zindex = 0;
    }

    public void addObject(GraphicsObject obj) {
        throw new RuntimeException("Operation not supported!");
    }

    public void removeObject(GraphicsObject obj) {
        throw new RuntimeException("Operation not supported!");
    }

    public int getCount() {
        return 0;
    }

    public GraphicsObject getObject(int index) {
        return null;
    }

    public Color getBackgroundColor() {
        return bgColor;
    }

    public void setBackgroundColor(Color c) {
        this.bgColor = c;
    }

    public Rectangle getBounds() {
        return bounds;
    }

    public void setBounds(Rectangle r) {
        this.bounds = r;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String t) {
        title = t;
    //setChanged();
    //  notifyObservers(this);
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    //  setChanged();
    //  notifyObservers(this);
    }

    public boolean isSelected() {
        return this.selected;
    }

    public void setZorder(int z) {
        this.zindex = z;
    }

    public int getZorder() {
        return this.zindex;
    }

    public int compareTo(Object o) {
        GraphicsObject t = (GraphicsObject) o;
        return getZorder() - t.getZorder();
    }
}
